When a resource is shared by a plurality of information processors in a multiple information processing system (multiprocessor system) in which processes are concurrently executed by the plurality of information processors, it is necessary to exclusively control the sharable resource (mutual exclusion) between the information processors in order to ensure a consistency in sharing the resource.
The consistency in sharing the resource was conventionally supported, for example, as described below. An information processor acquires a right of prior use of a sharable resource in a lock object and then uses the sharable resource. When the sharable resource is no longer used, the information processor returns the right of prior use to release the sharable resource. This conventional method prevents a plurality of information processors from accessing the sharable resource at the same time, thereby supporting the consistency in sharing the resource. Hereinafter, “lock” is a term used to express acquisition of a right of prior use of a sharable resource in a lock object, and “unlock” is a term used to express returning the right of prior use to release the sharable resource.
There are two standby operations for exclusive control carried out by the lock object to lock the sharable resource; spin lock operation, and suspend lock operation. Describing the spin lock operation, an information processor repeatedly checks the lock object until the lock succeeds. The standby operation called the suspend lock standby operation is described below. When an information processor (first information processor) fails to achieve the lock because of the ongoing lock for the sharable resource in the lock object won by another information processor (second information processor), the first information processor switches its own process to execute from a first process which requires the lock for the sharable resource to a second process which does not require the lock for the sharable resource (context switch), making the first process sleep. When the lock won by the second information processor for the sharable resource is thereafter is released, the first information processor attempts again to achieve the lock for the sharable resource from the lock object, and then switches the process back to the first process from the second process (wakeup) when the attempt is successful. The “suspend” used in the term means putting the first process “on hold”.
The spin lock operation leaves the information processor busy-waiting to disallow the information processor to execute any other process during the spin (sleep) of the first process, thereby creating a processing idle time in the information processor as a resource device.
When an attempt to win the lock fails during the suspend lock operation, a right of execution in the first information processor is transferred from the first process to the second process. Therefore, there is no processing idle time in the first information processor. The suspend lock operation, however, still needs a processing time for the context switch to make the process sleep and wake up, thereby increasing an overhead (overall processing time).
To solve these technical problems, the two standby operations are conventionally switched to and from each other in a timely manner. There are two manners of operation switching; static switching and dynamic switching. The static switching has the following disadvantages; the spin continues as long the lock fails even over a long period of time, and the sleep is inevitable although the lock will succeed soon, thereby creating a processing idle time in the information processor as a resource device. Therefore, the dynamic switching is attracting attention.
The technical ideas of the dynamic switching thus far disclosed are; determine whether a lock-winning process is in execution (whether the process is granted a right of execution by an information processor) and decide which of the standby operations should be selected based on a determination result thereby obtained (see the Patent Document 1, hereinafter, called prior art 1), and attempt the lock during the spin lock operation and switch to the suspend lock operation if the lock still fails after the sleep over a given period of time (see the Patent Document 2, hereinafter, called prior art 2).